package game.module.club.processor;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import game.common.PlayingRoleMsgProcessor;
import game.entity.PlayingRole;
import game.module.club.logic.ClubManager;
import lion.common.MsgCodeAnn;
import lion.netty4.message.MyRequestMessage;
import lion.netty4.message.RequestMessageRaw;
import lion.netty4.message.RequestProtoMessage;
import lua.LuaMessageHall.C2SClubMember;
import lua.LuaMessageHall.S2CClubMember;
import lua.LuaMessageLogin.S2ErrorCode;

/**
 *@author: Pomelo.Lee
 *@date: 2017年8月31日 下午1:21:35
 */
@MsgCodeAnn(msgcode = C2SClubMember.id, accessLimit = 500)
public class ClubMemberProcessor extends PlayingRoleMsgProcessor {

	private static Logger logger = LoggerFactory.getLogger(ClubMemberProcessor.class);

	@Override
	public void process(PlayingRole playingRole, RequestMessageRaw requestMessage) throws Exception {
		C2SClubMember req = C2SClubMember.parse(requestMessage);
		int playerId = playingRole.getId();
		logger.info("player club member ,playerId={},clubId={}", playerId, req.club_id);

		S2CClubMember respMsg = new S2CClubMember();
		int resp = ClubManager.getInstance().listClubMember(playingRole, req.club_id, req.p, respMsg);
		if (resp != 1) {
			S2ErrorCode retMsg = new S2ErrorCode(resp);
			playingRole.writeAndFlush(retMsg.build(playingRole.alloc()));
			return;
		}

		playingRole.writeAndFlush(respMsg.build(playingRole.alloc()));
	}

	@Override
	public void processProto(PlayingRole playingRole, RequestProtoMessage request) throws Exception {
		// TODO Auto-generated method stub

	}

	@Override
	public void processWebsocket(PlayingRole playingRole, MyRequestMessage request) throws Exception {
		// TODO Auto-generated method stub

	}

}
